<template>
    <div class="test_demo">
        <button open-type="getUserInfo" @getUserinfo="getUserInfo" @click="getUserInfo1">获取权限</button>
    </div>
</template>
<script>
// import {login} from '@/utils/wx.js'
export default {
  name: 'demo_test',
  onShow () {
    // this.login((res) => {
    //   console.log(res)
    // })
    this.getSetting()
  },
  methods: {
    jump () {
      console.log(this, '==this==')
      this.$router.push({path: '/pages/test/test'})
    },
    getSetting () {
      wx.getSetting({
        success: (res) => {
          if (res.authSetting['scope.userInfo']) {
            wx.getUserInfo({
              success: function (res) {
                console.log(res.userInfo)
                console.log('用户已经授权过')
              }
            })
          } else {
            // 还没有授权
          }
        }
      })
    },
    getUserInfo (e) {
      if (e.mp.detail.rawData) {
        console.log('用户点击了同意授权')
      } else {
        console.log('用户拒绝了授权')
      }
    }

  }
}
</script>
<style lang="scss" scoped>
.test_demo {
  div{
    background: url('../../assets/imgs/ic_menu_choice_nor.png') no-repeat;
    background-size: cover;
    display: block;
    width: 50rpx;
    height: 50rpx;
    border: 1rpx solid #ccc;
  }
}
</style>

